<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title></title>
	<style type="text/css">
		.box{
			width: 200px;
			height: 200px;
			background: red url() 0 0 no-repeat;
		}
	</style>
	<script type="text/javascript">
		window.onload = function  () {
			//捉取标签
			box = document.getElementById("box");
			btn = document.getElementById("btn");

			// 得到的宽高
			width = window.getComputedStyle ? window.getComputedStyle(box,null).width :box.currentStyle.width;
			height = window.getComputedStyle ? window.getComputedStyle(box,null).height :box.currentStyle.height;

			//转整
			width= parseInt(width);
			height= parseInt(height);

			x = 0

			function run () {

				
				if(x==0){
					height+=10;
					width +=10;
				}else{
					height-=10;
					width -=10;	
				}

				if(height==400){
					x=1;
				}else if(height==200){
					x=0;
				}

				box.style.width=width+'px';
				box.style.height=height+'px';
				
			}


			//增加事件
			btn.onclick = function  (argument) {
				if(btn.getAttribute('value')=='开始'){
					btn.setAttribute('value',"停止");
					time = setInterval(run, 10);
				}else{
					btn.setAttribute('value',"开始");
					clearInterval(time);
				}
				
				
			}

		}

	</script>

</head>
<body>
	<input type="button" id="btn" value="开始">
	<div class="box"  id="box">
		
	</div>
</body>
</html>